import { createRouter, createWebHistory } from 'vue-router'
import ControlPanel from '../views/ControlPanel.vue'
import ScreenDisplay from '../views/ScreenDisplay.vue'
import ScreenRouter from '../views/ScreenRouter.vue'
import HomePage from '../views/screen/HomePage.vue'
import OverviewPage from '../views/screen/OverviewPage.vue'
import MonitorPage from '../views/screen/MonitorPage.vue'
import StatisticsPage from '../views/screen/StatisticsPage.vue'
import SettingsPage from '../views/screen/SettingsPage.vue'

const routes = [
  {
    path: '/',
    redirect: '/control'
  },
  {
    path: '/control',
    name: 'ControlPanel',
    component: ControlPanel,
    meta: { title: '控制面板' }
  },
  {
    path: '/pagescreen',
    name: 'ScreenDisplay',
    component: ScreenDisplay,
    meta: { title: '大屏显示' }
  },
  {
    path: '/screen',
    name: 'ScreenRouter',
    component: ScreenRouter,
    meta: { title: '路由大屏' },
    children: [
      {
        path: '',
        redirect: '/screen/home'
      },
      {
        path: 'home',
        name: 'HomePage',
        component: HomePage,
        meta: { title: '首页' }
      },
      {
        path: 'overview',
        name: 'OverviewPage',
        component: OverviewPage,
        meta: { title: '数据概览' }
      },
      {
        path: 'monitor',
        name: 'MonitorPage',
        component: MonitorPage,
        meta: { title: '实时监控' }
      },
      {
        path: 'statistics',
        name: 'StatisticsPage',
        component: StatisticsPage,
        meta: { title: '统计分析' }
      },
      {
        path: 'settings',
        name: 'SettingsPage',
        component: SettingsPage,
        meta: { title: '系统设置' }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '数据大屏远程配置系统'
  next()
})

export default router 